Ext.define('appfe.stockor.exec.ExecHoldModel', {
    extend: 'Ext.app.ViewModel',
    alias: 'viewmodel.stockor.exec.ExecHold',
    data: {
        refreshing: false,
        totalProfitSum: 0
    },
    formulas: {
        formulaTotalProfitSum: function (get) {
            var tmpSum = get('totalProfitSum');
            var color;
            if (tmpSum > 0) {
                color = 'color:#dd2200';
            } else if (tmpSum < 0) {
                color = 'color:#009933';
            }
            return '<span style="font-size: 16px;font-weight: bold;' + color + '">' + (tmpSum > 0 ? 'Ұ+' : 'Ұ') + Ext.util.Format.number(tmpSum, '0.00') + '</span>';
        }
    },
    stores: {
        refreshIntervalStore: {
            fields: ['text', 'interval', 'tips'],
            data: [
                ['无', 0, ''],
                ['5秒', 5000, '自动刷新时, 冻结持仓股票的增删改操作'],
                ['10秒', 10000, '自动刷新时, 冻结持仓股票的增删改操作'],
                ['30秒', 30000, '自动刷新时, 冻结持仓股票的增删改操作'],
                ['1分钟', 60000, '自动刷新时, 冻结持仓股票的增删改操作'],
                ['5分钟', 300000, '自动刷新时, 冻结持仓股票的增删改操作']
            ]
        },
        queryKeyStore: {
            fields: ['text', 'code', 'type'],
            data: [
                ['简码', 'slimsymbol', 'string'],
                ['名称', 'name', 'string']
            ]
        },
        execHoldStatusStore: {
            fields: ['text', 'code', 'tip'],
            data: [
                ['持仓', 'HOLD', '持仓'],
                ['观察', 'WACH', '观察'],
                ['清仓', 'SOLD', '清仓']
            ]
        },
        execHoldStore: {
            fields: [
                { name: 'id', type: 'int' },
                { name: 'slimsymbol', type: 'string' },
                { name: 'name', type: 'string' },
                { name: 'holdVolume', type: 'int' },
                { name: 'unitCost', type: 'string' },
                { name: 'totalCost', type: 'int' },
                { name: 'monitorSelloutBarriePrice', type: 'string' },
                { name: 'monitorSelloutExecPrice', type: 'string' },
                { name: 'monitorSelloutExecVolume', type: 'string' },
                { name: 'current', type: 'float' },
                { name: 'timestamp', type: 'date' },
                { name: 'lastClose', type: 'float' },
                { name: 'open', type: 'float' },
                { name: 'high', type: 'float' },
                { name: 'low', type: 'float' },
                { name: 'chg', type: 'float' },
                { name: 'percent', type: 'float' },
                { name: 'amplitude', type: 'float' },
                { name: 'volume', type: 'float' },
                { name: 'amount', type: 'float' },
                { name: 'unitProfit', type: 'float' },
                { name: 'profitRatio', type: 'float' },
                { name: 'totalProfit', type: 'float' },
                { name: 'createDate', type: 'date' },
                { name: 'modifyDate', type: 'date' },
                { name: 'status', type: 'string' },
                { name: 'suggestions', type: 'string' },
                { name: 'comments', type: 'string' }
            ],
            autoLoad: false, //不自动加载, 只有用户查询的时候才load数据, 
            remoteSort: true,
            proxy: {
                type: 'ajax',
                url: BizHttpAction.queryExecStockHoldRealTimeVO.url,
                method: BizHttpAction.queryExecStockHoldRealTimeVO.method,
                reader: {
                    type: 'json',
                    rootProperty: 'data',
                    totalProperty: 'total',
                    successProperty: 'success'
                },
                simpleSortMode: true // sends single sort as multi parameter
            },
            sorters: [
                { property: 'createDate', direction: 'DESC' }
            ]
        }
    }
});
